<script setup lang="ts">

defineComponent({
  name: 'AvatarCard'
})
const props = defineProps({
  item: {
    type: Object,
    required: true
  }
})

const Base_URL = import.meta.env.BASE_URL

const openAvatar = () => {
  // 查看浏览器有没有打开对应的标签页，如果有的话直接跳到对应的标签页，否则打开新的标签页
  const url = Base_URL + 'article/details/' + props.item.artId;
  window.open(url, props.item.artId);
}

</script>

<template>
  <div class="card box-shadow-card" @click="openAvatar">
    <div class="card-img">
      <img :src="item.artCoverUrl"/>
    </div>
    <div class="card-content">
      <div class="avatar-publish">
        <SvgIcon icon-class="blog-date"></SvgIcon>&nbsp;发布于&nbsp;{{ item.publishTime }}
      </div>
      <span class="avatar-title">{{ item.artTitle }}</span>
      <div class="avatar-comment-like">
        <SvgIcon icon-class="blog-comment"></SvgIcon>&nbsp;3 条评论&nbsp;&nbsp;
        <SvgIcon icon-class="blog-like"></SvgIcon>&nbsp;3 点赞
      </div>
      <div class="content-tags">
        <div class="other-tag-item">
          <SvgIcon icon-class="blog-live"></SvgIcon>&nbsp;生活倒影
        </div>
        <div class="other-tag-item">
          <SvgIcon icon-class="blog-comment"></SvgIcon>&nbsp;生活倒影
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.card {
  width: 300px;
  height: 300px;
  display: flex;
  flex-direction: column;
  background-color: #FFFFFF;

  .card-img {
    width: 100%;
    height: 188px;
    overflow: hidden;

    img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      transition: all 0.5s;

      &:hover {
        cursor: pointer;
        /*图片变大*/
        transform: scale(1.2);
      }
    }
  }


  .card-content {
    padding: 8px 16px;
    color: #7C7C7C;

    .avatar-publish {
      align-items: center;
      font-size: 14px;
      line-height: 14px;
    }

    .avatar-title {
      font-size: 18px;
      line-height: 38px;
      font-weight: bold;
      color: #333333;
    }

    .avatar-comment-like {
      font-weight: 400;
      font-size: 12px;
      display: flex;
      align-items: center;
      line-height: 20px;
    }

    .content-tags {
      display: flex;
      align-items: center;

      .other-tag-item {
        font-size: 12px;
        line-height: 20px;
        display: flex;
        align-items: center;
        padding: 0 6px;
        background-color: #EEEEEE;
        margin-right: 13px;
        border-radius: 2px;
      }
    }

  }


}
</style>
